package selenium;

import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import pages.HomePage;
import util.ReportWriter;


public class PositiveAuthorisation extends TestConditions
{

    @DataProvider(name = "loginTest")
    public Object[][] provideData()
    {
        return new Object[][]
                {
                        new Object[] {"vivaniv@i.ua", "vivaniv321"},
                };
    }

    @Test (dataProvider = "loginTest")
    public void logIn(String email,String password) throws InterruptedException {
        HomePage homePage = new HomePage(driver);
        homePage.open();
        homePage.logIn(email,password);
        Thread.sleep(3000);
        Assert.assertTrue(homePage.isLoggedIn(), ReportWriter.error("Login test FAIL"));
    }

    @Test (dependsOnMethods = "logIn")
    public void logOut() throws InterruptedException {
        HomePage homePage = new HomePage(driver);
        homePage.logOut();
        Thread.sleep(1500);
        Assert.assertFalse(homePage.isLoggedIn(), ReportWriter.error("Logout test FAIL"));
    }
}
